package collection;

import java.util.HashMap;
import java.util.Map;

public class MapT {
    public static void main(String[] args) {
        String[] arr={"a","b","a","b","c","a","b","c","b"};
        Map<String,Integer> map=new HashMap<>();
        for(String s:arr){
            map.put(s,map.getOrDefault(s,0)+1);//当s存在map+1并且初始化为1
        }
        System.out.println(map);
    }
}
